package org.elec.mac.utils;

import org.elec.mac.entity.SFormula;
import org.elec.mac.entity.SMachineMaterial;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by wangtao on 2018/6/28.
 */
public class Maxcup {

    //最大可做杯数
    public static Integer result(List<SFormula> sFormulaList,List<SMachineMaterial> sMachineMaterialList)
            throws Exception {

        List<Integer> array = new ArrayList<>();

        for(int i = 0; i < sFormulaList.size(); i++){
            for (int j = 0; j < sMachineMaterialList.size(); j++) {
                if(sFormulaList.get(i).getMaid().equals(sMachineMaterialList.get(j).getMid())) {
                    array.add(sMachineMaterialList.get(j).getAmount()/sFormulaList.get(i).getAmount());
                    break;
                }
            }
        }

        return Collections.min(array);
    }
}
